import { Component } from '@angular/core';

import { CalculateService } from './calculate.service';

export class Button {
  name: string;
}

const BUTTONS: Button[] = [
  { name: '+' },
  { name: '-' },
  { name: '*' },
  { name: '/' },

  { name: '1' },
  { name: '2' },
  { name: '3' },
  { name: '4' }

];

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {

  constructor(private calculateService: CalculateService) {
    this.calculateService = calculateService;
  }

  title = '简易计算器';
  buttons = BUTTONS;
  display = 0;
  onSelect(button: Button): void {
    this.display = this.calculateService.calculate(button.name);
  }
}
